package com.tools.common.object.json.deserializer;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.tools.common.object.C;
import com.tools.common.object.Note;
import com.tools.common.object.json.JsonKit;
import com.tools.db.ip.IPBean;

import java.io.IOException;

/**
 * IPBean 对象的类型处理器逻辑
 * */
@Note("IPBean 对象的类型处理器逻辑")
public class IPBeanTypeHandler {

    private IPBeanTypeHandler() {}

    @Note("IPBean 对象的反序列化逻辑")
    public static StdDeserializer<IPBean> ipBeanStdDeserializer() {
        return new StdDeserializer<IPBean>(IPBean.class) {
            @Override
            public IPBean deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException {
                return (IPBean) JsonKit.parseToken(jsonParser, C.build(IPBean.class));
            }
        };
    }
}
